home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / ADSP.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  10KB  |  275 lines

  1. /*
  2.      File:        ADSP.h
  3.  
  4.      Contains:    AppleTalk Data Stream Protocol (ADSP) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __ADSP__
  19. #define __ADSP__
  20.  
  21. #ifndef __ERRORS__
  22. #include <Errors.h>
  23. #endif
  24. #ifndef __APPLETALK__
  25. #include <AppleTalk.h>
  26. #endif
  27.  
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31.  
  32. #if PRAGMA_IMPORT_SUPPORTED
  33. #pragma import on
  34. #endif
  35.  
  36. #if PRAGMA_ALIGN_SUPPORTED
  37. #pragma options align=mac68k
  38. #endif
  39.  
  40. #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
  41. /*Error Codes have been moved to Errors.(pah) */
  42. /*driver control csCodes*/
  43.  
  44. enum {
  45.     dspInit                        = 255,                            /* create a new connection end */
  46.     dspRemove                    = 254,                            /* remove a connection end */
  47.     dspOpen                        = 253,                            /* open a connection */
  48.     dspClose                    = 252,                            /* close a connection */
  49.     dspCLInit                    = 251,                            /* create a connection listener */
  50.     dspCLRemove                    = 250,                            /* remove a connection listener */
  51.     dspCLListen                    = 249,                            /* post a listener request */
  52.     dspCLDeny                    = 248,                            /* deny an open connection request */
  53.     dspStatus                    = 247,                            /* get status of connection end */
  54.     dspRead                        = 246,                            /* read data from the connection */
  55.     dspWrite                    = 245,                            /* write data on the connection */
  56.     dspAttention                = 244                            /* send an attention message */
  57. };
  58.  
  59.  
  60. enum {
  61.     dspOptions                    = 243,                            /* set connection end options */
  62.     dspReset                    = 242,                            /* forward reset the connection */
  63.     dspNewCID                    = 241,                            /* generate a cid for a connection end */
  64.                                                                 /* connection opening modes */
  65.     ocRequest                    = 1,                            /* request a connection with remote */
  66.     ocPassive                    = 2,                            /* wait for a connection request from remote */
  67.     ocAccept                    = 3,                            /* accept request as delivered by listener */
  68.     ocEstablish                    = 4,                            /* consider connection to be open */
  69.                                                                 /* connection end states */
  70.     sListening                    = 1,                            /* for connection listeners */
  71.     sPassive                    = 2,                            /* waiting for a connection request from remote */
  72.     sOpening                    = 3,                            /* requesting a connection with remote */
  73.     sOpen                        = 4,                            /* connection is open */
  74.     sClosing                    = 5,                            /* connection is being torn down */
  75.     sClosed                        = 6,                            /* connection end state is closed */
  76.                                                                 /* client event flags */
  77.     eClosed                        = 0x80,                            /* received connection closed advice */
  78.     eTearDown                    = 0x40,                            /* connection closed due to broken connection */
  79.     eAttention                    = 0x20,                            /* received attention message */
  80.     eFwdReset                    = 0x10,                            /* received forward reset advice */
  81.                                                                 /* miscellaneous constants */
  82.     attnBufSize                    = 570,                            /* size of client attention buffer */
  83.     minDSPQueueSize                = 100                            /* Minimum size of receive or send Queue */
  84. };
  85.  
  86. /* connection control block */
  87. typedef struct TRCCB TRCCB;
  88. typedef TRCCB *TPCCB;
  89. struct TRCCB {
  90.     TPCCB                             ccbLink;                    /* link to next ccb */
  91.     UInt16                             refNum;                        /* user reference number */
  92.     UInt16                             state;                        /* state of the connection end */
  93.     UInt8                             userFlags;                    /* flags for unsolicited connection events */
  94.     UInt8                             localSocket;                /* socket number of this connection end */
  95.     AddrBlock                         remoteAddress;                /* internet address of remote end */
  96.     UInt16                             attnCode;                    /* attention code received */
  97.     UInt16                             attnSize;                    /* size of received attention data */
  98.     void *                            attnPtr;                    /* ptr to received attention data */
  99.     UInt8                             reserved[220];                /* for adsp internal use */
  100. };
  101.  
  102. /*
  103.         This ProcPtr uses register based parameters on the 68k and cannot
  104.         be written in or called from a high-level language without the help of
  105.         mixed mode or assembly glue.
  106.  
  107.             typedef pascal void (*ADSPConnectionEventProcPtr)(TPCCB sourceCCB);
  108.  
  109. */
  110. typedef struct DSPParamBlock DSPParamBlock;
  111. typedef DSPParamBlock *DSPPBPtr;
  112. /*
  113.         This ProcPtr uses register based parameters on the 68k and cannot
  114.         be written in or called from a high-level language without the help of
  115.         mixed mode or assembly glue.
  116.  
  117.             typedef pascal void (*ADSPCompletionProcPtr)(DSPPBPtr thePBPtr);
  118.  
  119. */
  120.  
  121. #if GENERATINGCFM
  122. typedef UniversalProcPtr ADSPConnectionEventUPP;
  123. typedef UniversalProcPtr ADSPCompletionUPP;
  124. #else
  125. typedef Register68kProcPtr ADSPConnectionEventUPP;
  126. typedef Register68kProcPtr ADSPCompletionUPP;
  127. #endif
  128. struct TRinitParams {
  129.     TPCCB                             ccbPtr;                        /* pointer to connection control block */
  130.     ADSPConnectionEventUPP             userRoutine;                /* client routine to call on event */
  131.     UInt16                             sendQSize;                    /* size of send queue (0..64K bytes) */
  132.     void *                            sendQueue;                    /* client passed send queue buffer */
  133.     UInt16                             recvQSize;                    /* size of receive queue (0..64K bytes) */
  134.     void *                            recvQueue;                    /* client passed receive queue buffer */
  135.     void *                            attnPtr;                    /* client passed receive attention buffer */
  136.     UInt8                             localSocket;                /* local socket number */
  137.     UInt8                             filler1;                    /* filler for proper byte alignment */
  138. };
  139. typedef struct TRinitParams TRinitParams;
  140.  
  141. struct TRopenParams {
  142.     UInt16                             localCID;                    /* local connection id */
  143.     UInt16                             remoteCID;                    /* remote connection id */
  144.     AddrBlock                         remoteAddress;                /* address of remote end */
  145.     AddrBlock                         filterAddress;                /* address filter */
  146.     UInt32                             sendSeq;                    /* local send sequence number */
  147.     UInt16                             sendWindow;                    /* send window size */
  148.     UInt32                             recvSeq;                    /* receive sequence number */
  149.     UInt32                             attnSendSeq;                /* attention send sequence number */
  150.     UInt32                             attnRecvSeq;                /* attention receive sequence number */
  151.     UInt8                             ocMode;                        /* open connection mode */
  152.     UInt8                             ocInterval;                    /* open connection request retry interval */
  153.     UInt8                             ocMaximum;                    /* open connection request retry maximum */
  154.     UInt8                             filler2;                    /* filler for proper byte alignment */
  155. };
  156. typedef struct TRopenParams TRopenParams;
  157.  
  158. struct TRcloseParams {
  159.     UInt8                             abort;                        /* abort connection immediately if non-zero */
  160.     UInt8                             filler3;                    /* filler for proper byte alignment */
  161. };
  162. typedef struct TRcloseParams TRcloseParams;
  163.  
  164. struct TRioParams {
  165.     UInt16                             reqCount;                    /* requested number of bytes */
  166.     UInt16                             actCount;                    /* actual number of bytes */
  167.     void *                            dataPtr;                    /* pointer to data buffer */
  168.     UInt8                             eom;                        /* indicates logical end of message */
  169.     UInt8                             flush;                        /* send data now */
  170. };
  171. typedef struct TRioParams TRioParams;
  172.  
  173. struct TRattnParams {
  174.     UInt16                             attnCode;                    /* client attention code */
  175.     UInt16                             attnSize;                    /* size of attention data */
  176.     void *                            attnData;                    /* pointer to attention data */
  177.     UInt8                             attnInterval;                /* retransmit timer in 10-tick intervals */
  178.     UInt8                             filler4;                    /* filler for proper byte alignment */
  179. };
  180. typedef struct TRattnParams TRattnParams;
  181.  
  182. struct TRstatusParams {
  183.     TPCCB                             statusCCB;                    /* pointer to ccb */
  184.     UInt16                             sendQPending;                /* pending bytes in send queue */
  185.     UInt16                             sendQFree;                    /* available buffer space in send queue */
  186.     UInt16                             recvQPending;                /* pending bytes in receive queue */
  187.     UInt16                             recvQFree;                    /* available buffer space in receive queue */
  188. };
  189. typedef struct TRstatusParams TRstatusParams;
  190.  
  191. struct TRoptionParams {
  192.     UInt16                             sendBlocking;                /* quantum for data packets */
  193.     UInt8                             sendTimer;                    /* send timer in 10-tick intervals */
  194.     UInt8                             rtmtTimer;                    /* retransmit timer in 10-tick intervals */
  195.     UInt8                             badSeqMax;                    /* threshold for sending retransmit advice */
  196.     UInt8                             useCheckSum;                /* use ddp packet checksum */
  197. };
  198. typedef struct TRoptionParams TRoptionParams;
  199.  
  200. struct TRnewcidParams {
  201.     UInt16                             newcid;                        /* new connection id returned */
  202. };
  203. typedef struct TRnewcidParams TRnewcidParams;
  204.  
  205. struct DSPParamBlock {
  206.     QElem *                            qLink;
  207.     short                             qType;
  208.     short                             ioTrap;
  209.     Ptr                             ioCmdAddr;
  210.     ADSPCompletionUPP                 ioCompletion;
  211.     OSErr                             ioResult;
  212.     StringPtr                         ioNamePtr;
  213.     short                             ioVRefNum;
  214.     short                             ioCRefNum;                    /* adsp driver refNum */
  215.     short                             csCode;                        /* adsp driver control code */
  216.     long                             qStatus;                    /* adsp internal use */
  217.     short                             ccbRefNum;
  218.     union {
  219.         TRinitParams                     initParams;
  220.         TRopenParams                     openParams;
  221.         TRcloseParams                     closeParams;            /*dspClose, dspRemove*/
  222.         TRioParams                         ioParams;                /*dspRead, dspWrite*/
  223.         TRattnParams                     attnParams;                /*dspAttention*/
  224.         TRstatusParams                     statusParams;            /*dspStatus*/
  225.         TRoptionParams                     optionParams;            /*dspOptions*/
  226.         TRnewcidParams                     newCIDParams;            /*dspNewCID*/
  227.     }                                 u;
  228. };
  229.  
  230.  
  231. enum {
  232.     uppADSPConnectionEventProcInfo = kRegisterBased
  233.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA1, SIZE_CODE(sizeof(TPCCB))),
  234.     uppADSPCompletionProcInfo = kRegisterBased
  235.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA0, SIZE_CODE(sizeof(DSPPBPtr)))
  236. };
  237.  
  238. #if GENERATINGCFM
  239. #define NewADSPConnectionEventProc(userRoutine)        \
  240.         (ADSPConnectionEventUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppADSPConnectionEventProcInfo, GetCurrentArchitecture())
  241. #define NewADSPCompletionProc(userRoutine)        \
  242.         (ADSPCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppADSPCompletionProcInfo, GetCurrentArchitecture())
  243. #else
  244. #define NewADSPConnectionEventProc(userRoutine)        \
  245.         ((ADSPConnectionEventUPP) (userRoutine))
  246. #define NewADSPCompletionProc(userRoutine)        \
  247.         ((ADSPCompletionUPP) (userRoutine))
  248. #endif
  249.  
  250. #if GENERATINGCFM
  251. #define CallADSPConnectionEventProc(userRoutine, sourceCCB)        \
  252.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppADSPConnectionEventProcInfo, (sourceCCB))
  253. #define CallADSPCompletionProc(userRoutine, thePBPtr)        \
  254.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppADSPCompletionProcInfo, (thePBPtr))
  255. #else
  256. /* (*ADSPConnectionEventUPP) cannot be called from a high-level language without the Mixed Mode Manager */
  257. /* (*ADSPCompletionUPP) cannot be called from a high-level language without the Mixed Mode Manager */
  258. #endif
  259. #endif
  260.  
  261. #if PRAGMA_ALIGN_SUPPORTED
  262. #pragma options align=reset
  263. #endif
  264.  
  265. #if PRAGMA_IMPORT_SUPPORTED
  266. #pragma import off
  267. #endif
  268.  
  269. #ifdef __cplusplus
  270. }
  271. #endif
  272.  
  273. #endif /* __ADSP__ */
  274.  
  275.